<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${ctx}/static/lib/layui/css/layui.css">
</head>
<style type="text/css">
	.main_div{
		margin : 15px;
	}
</style>

<body>

<form class="layui-form layui-form-pane" action="" id="form_add">
  <div class="layui-form-item">
    <label class="layui-form-label">权限管理</label>
    <div class="layui-input-block">
    <!--lay-verify="required" 这个语句是自带的正则表达式，包含的意思是 该文本框不能为空(必填项) -->
      <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入权限名称" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">权限访问地址</label>
    <div class="layui-input-block">
      <input type="text" name="resource" lay-verify="required"  placeholder="请输入权限访问地址" autocomplete="off" class="layui-input">
    </div>
  </div>
  <!--提交按钮开始 -->
  <div class="layui-form-item">
    <input class="layui-btn" onclick="submitForm()" lay-filter="demo2" value="添加" />
  </div>
</form>
  <!--提交按钮结束 -->
          
<script src="${ctx}/static/back/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctx}/static/common/mylayer.js"></script>
<script src="${ctx}/static/common/util.js"></script>
<script src="${ctx}/static/lib/layui/layui.js"></script>
<script src="${ctx}/static/lib/kindeditor/kindeditor.js"></script>
<script src="${ctx}/static/lib/kindeditor/lang/zh_CN.js"></script>
<!--layer弹窗测试  -->
<script>
	layui.use(['layer'],function() {
		var layer = layui.layer;
	});
	function submitForm() {
		//ajax方式提交表单
		$.ajax({
			url:"${ctx}/permission/insert.action",
			//data提交，序列化
			data:$('#form_add').serialize(),
			type:"POST",
			dataType:"json",
			success :function (resp) {
				if (resp.code == util.SUCCESS) {
					mylayer.confirm("添加成功，是否跳转到列表界面？","${ctx}/permission/getPage.action");
				}else{
					mylayer.errorMsg(resp.msg);					
				}
			}
		}); 
	}
</script>
</body>
</html>